package zigzag.designpattern.prototype;

/*
 * ZigzagSoft.net
 * Copyright 2006-2008 Jerry Chan
 * Email : jerry.chan.cn@gmail.com
 *
 * These sources may be copied, modified and distributed only for
 * projects undertaken by Jerry Chan, or with the agreement by the author.
 * Any enhancement/changes/suggestion to the source is welcome and is to
 * keep the author informed.
*/

public class Client {
    public static void main(String args[]) {
        System.out.println("Shallow Clone");
        AbstractArchitect a1 = new Architect();
        a1.buildRoom("4 rooms");
        a1.buildGarden("beautiful garden");

        AbstractArchitect a2 = (AbstractArchitect) a1.clone();

        System.out.println("A1:" + a1.house.getRoom() + "," + a1.house.getGarden());
        System.out.println("A2:" + a2.house.getRoom() + "," + a2.house.getGarden());

        a1.buildRoom("50 rooms");
        a1.buildGarden("ugly garden");

        System.out.println("A1:" + a1.house.getRoom() + "," + a1.house.getGarden());
        System.out.println("A2:" + a2.house.getRoom() + "," + a2.house.getGarden());

        System.out.println("\nDeep Clone");
        DeepCloneAbstractArchitect b1 = new DeepCloneArchitect();
        b1.buildRoom("4 rooms");
        b1.buildGarden("beautiful garden");

        DeepCloneAbstractArchitect b2 = (DeepCloneAbstractArchitect) b1.clone();

        System.out.println("B1:" + b1.house.getRoom() + "," + b1.house.getGarden());
        System.out.println("B2:" + b2.house.getRoom() + "," + b2.house.getGarden());

        b1.buildRoom("50 rooms");
        b1.buildGarden("ugly garden");

        System.out.println("B1:" + b1.house.getRoom() + "," + b1.house.getGarden());
        System.out.println("B2:" + b2.house.getRoom() + "," + b2.house.getGarden());


    }
}
